<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>显示当前系统时间</button>
    <div>某个时间</div>
    <script>
        //当我们点击按钮，div里面的文字会发生变化
        //获取事件源
        let btn = document.querySelector('button');
        let div = document.querySelector('div');
        //时间类型
        btn.onclick = function () {
            div.innerText = getSystemTime();
        }

        function getSystemTime() {
            // 实例化日期类
            var time = new Date();
            //打印得到时间
            document.write(time.toLocaleString());

        }

    </script>
</body>

</html>